package equation;

import java.util.Objects;

public class EquationFactory {

    public EquationFactory() {
    }

    // 采用工厂设计模式的工厂方法
    public Equation getEquation(String equationType, Integer operandA, Integer operandB) {
        Equation equation = null;
        if (Objects.equals(equationType, "AddEquation")) {
            equation = new AddEquation(operandA, operandB);
        } else if (Objects.equals(equationType, "MultiplyEquation")) {
            equation = new MultiplyEquation(operandA, operandB);
        } else if (Objects.equals(equationType, "SubEquation")) {
            equation = new SubEquation(operandA, operandB);
        } else if (Objects.equals(equationType, "DivideEquation")) {
            equation = new DivideEquation(operandA, operandB);
        }
        return equation;
    }

}
